/**
  ******************************************************************************
  * @file    HCI_CFG.h
  * @author  Feirui_Joe
  * @version V0.1
  * @date    07/26/2010
  * @brief   Outputs Driver
  ******************************************************************************
  * @copy
  *
  * <h2><center>&copy; COPYRIGHT 2010 Feirui</center></h2>
  */ 



/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef  __HCI_CFG_H__
#define  __HCI_CFG_H__


#ifdef __cplusplus
 extern "C" {
#endif


/**
  * @brief  INCLUDE FILES.
  */


/**
  * @brief GLOBALS RAM definition
  */
#ifdef   HCI_CFG_GLOBALS
#define  HCI_CFG_EXT
#else
#define  HCI_CFG_EXT  extern
#endif





/****************************************************/
/*********************LCD****************************/
/****************************************************/

#define DEF_LCDRowBitNum                 128
#define DEF_LCDColumnBitNum              240
#define DEF_LCDColumnByteNum             (DEF_LCDColumnBitNum/8)
#define DEF_LCDTOTByteNum                (DEF_LCDRowBitNum*DEF_LCDColumnByteNum)
HCI_CFG_EXT uint8_t LCDDotMatrixBuffer[DEF_LCDRowBitNum][DEF_LCDColumnByteNum];


#define LCMInitCommandTabNum              10
HCI_CFG_EXT const uint8_t LCMInitCommandTable[LCMInitCommandTabNum];


/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* set LCD command */
typedef struct
{
  uint32_t              RCC_APB2Periph  ;
  GPIOMode_TypeDef      GPIO_Mode       ;
  GPIOSpeed_TypeDef     GPIO_Speed      ;
  GPIO_TypeDef*         GPIOx           ;
  uint16_t              GPIO_Pin        ;
} LCMPortCfg_TypeDef;

#define LCMPortCfgNumber     5
HCI_CFG_EXT const LCMPortCfg_TypeDef LCMPortCfgTbl[LCMPortCfgNumber];



#define KeyShortPressPeriod                11              /* 1000/HCIKeyScanTimingFreq*11  ms = 0.55s  */
#define KeyPressGapPeriod                  3               /* 1000/HCIKeyScanTimingFreq*3   ms = 0.15s  */
#define KeyLongPressTouchPeriod            2               /* 1000/HCIKeyScanTimingFreq*4   ms = 0.10s  */ 
#define KeyNoisePeriod                     2

/****************************************************/
/******************Button and LED********************/
/****************************************************/

#define KeyHWBit_Stop                                      (DEF_BIT_00)
#define KeyHWBit_Manual                                    (DEF_BIT_01)
#define KeyHWBit_Test                                      (DEF_BIT_02)
#define KeyHWBit_Auto                                      (DEF_BIT_03)
#define KeyHWBit_ResetAlarm                                (DEF_BIT_04)
#define KeyHWBit_Start                                     (DEF_BIT_05)
#define KeyHWBit_GenLoad                                   (DEF_BIT_06)
#define KeyHWBit_MainLoad                                  (DEF_BIT_07)
#define KeyHWBit_Up                                        (DEF_BIT_08)
#define KeyHWBit_Enter                                     (DEF_BIT_09)
#define KeyHWBit_Down                                      (DEF_BIT_10)
#define KeyHWBit_Left                                      (DEF_BIT_11)
#define KeyHWBit_Right                                     (DEF_BIT_12)
#define KeyHWBit_ESC                                       (DEF_BIT_13)
#define KeyHWBit_TOTFun                                    (KeyHWBit_Stop|KeyHWBit_Manual|KeyHWBit_Test|KeyHWBit_Auto|KeyHWBit_ResetAlarm|KeyHWBit_Start|KeyHWBit_GenLoad|KeyHWBit_MainLoad)
#define KeyHWBit_TOTHCI                                    (KeyHWBit_Up|KeyHWBit_Enter|KeyHWBit_Down|KeyHWBit_Left|KeyHWBit_Right|KeyHWBit_ESC)


#ifdef UsingHW72xx

#define KeyValue_Stop                                      (DEF_BIT_00)
#define KeyValue_Manual                                    (DEF_BIT_01)
#define KeyValue_Test                                      (DEF_BIT_02)
#define KeyValue_Auto                                      (DEF_BIT_03)
#define KeyValue_ResetAlarm                                (DEF_BIT_04)
#define KeyValue_Start                                     (DEF_BIT_05)
#ifdef Module6620
#define KeyValue_GenLoad                                   (DEF_BIT_06)
#define KeyValue_MainLoad                                  (DEF_BIT_07)
#else
#define KeyValue_GenLoad                                   (DEF_BIT_07)
#define KeyValue_MainLoad                                  (DEF_BIT_14)
#endif
#define KeyValue_Up                                        (DEF_BIT_08)
#define KeyValue_Enter                                     (DEF_BIT_09)
#define KeyValue_Down                                      (DEF_BIT_10)
#define KeyValue_Left                                      (DEF_BIT_11)
#define KeyValue_Right                                     (DEF_BIT_12)
#define KeyValue_ESC                                       (DEF_BIT_13)

#else

#define KeyValue_Stop                                      (DEF_BIT_00)
#define KeyValue_Manual                                    (DEF_BIT_01)
#define KeyValue_Test                                      (DEF_BIT_02)
#define KeyValue_Auto                                      (DEF_BIT_03)
#define KeyValue_ResetAlarm                                (DEF_BIT_04)
#define KeyValue_Start                                     (DEF_BIT_05)
#ifdef Module6620
#define KeyValue_GenLoad                                   (DEF_BIT_06)
#define KeyValue_MainLoad                                  (DEF_BIT_07)
#else
#define KeyValue_GenLoad                                   (DEF_BIT_07)
#define KeyValue_MainLoad                                  (DEF_BIT_14)
#endif
#define KeyValue_Up                                        (DEF_BIT_08)
#define KeyValue_Down                                      (DEF_BIT_09)
#define KeyValue_Enter                                     (DEF_BIT_10)
#define KeyValue_Left                                      (DEF_BIT_11)
#define KeyValue_Right                                     (DEF_BIT_12)
#define KeyValue_ESC                                       (DEF_BIT_13)

#endif


#define KeyValue_Enter_Up                                  (KeyValue_Enter +KeyValue_Up   )
#define KeyValue_Enter_Down                                (KeyValue_Enter +KeyValue_Down )
#define KeyValue_Enter_Left                                (KeyValue_Enter +KeyValue_Left )
#define KeyValue_Enter_Right                               (KeyValue_Enter +KeyValue_Right)
#define KeyValue_Enter_Stop                                (KeyValue_Enter +KeyValue_Stop )
#define KeyValue_Hold_Enter                                (KeyValue_Hold  +KeyValue_Enter)
#define KeyValue_Hold_Up                                   (KeyValue_Hold  +KeyValue_Up   )
#define KeyValue_Hold_Down                                 (KeyValue_Hold  +KeyValue_Down )
#define KeyValue_Hold_Left                                 (KeyValue_Hold  +KeyValue_Left )
#define KeyValue_Hold_Right                                (KeyValue_Hold  +KeyValue_Right)
#define KeyValue_Hold_ESC                                  (KeyValue_Hold  +KeyValue_ESC  )
#define KeyValue_Hold_Stop                                 (KeyValue_Hold  +KeyValue_Stop )
#define KeyValue_Hold                                      (DEF_BIT_15)
#define KeyValue_Null                                      (DEF_BIT_NONE)

#define KeyVOrder_Stop                                      0
#define KeyVOrder_Manual                                    1
#define KeyVOrder_Test                                      2
#define KeyVOrder_Auto                                      3
#define KeyVOrder_ResetAlarm                                4
#define KeyVOrder_Start                                     5
#define KeyVOrder_GenLoad                                   6
#define KeyVOrder_MainLoad                                  7
#define KeyVOrder_Up                                        8
#define KeyVOrder_Enter                                     9
#define KeyVOrder_Down                                      10
#define KeyVOrder_Left                                      11
#define KeyVOrder_Right                                     12
#define KeyVOrder_ESC                                       13
#define KeyVOrder_Enter_Up                                  14
#define KeyVOrder_Enter_Down                                15
#define KeyVOrder_Enter_Left                                16
#define KeyVOrder_Enter_Right                               17
#define KeyVOrder_Enter_Stop                                18
#define KeyVOrder_Hold_Enter                                19
#define KeyVOrder_Hold_Up                                   20
#define KeyVOrder_Hold_Down                                 21
#define KeyVOrder_Hold_Left                                 22
#define KeyVOrder_Hold_Right                                23
#define KeyVOrder_Hold_ESC                                  24
#define KeyVOrder_Hold_Stop                                 25
#define KeyVOrder_TOTNum                                    26
#define KeyVOrder_LongHoldStop                              27
#define KeyVOrder_Null                                      0xff

#define LEDShowBitOrd_StopMode          DEF_BIT_00
#define LEDShowBitOrd_ManuMode          DEF_BIT_01
#define LEDShowBitOrd_TestMode          DEF_BIT_02
#define LEDShowBitOrd_AutoMode          DEF_BIT_03
#define LEDShowBitOrd_AudibleAlarm      DEF_BIT_04
#define LEDShowBitOrd_GenStatus         DEF_BIT_06
#ifdef Module6620                       
#define LEDShowBitOrd_GenOnLoad         DEF_BIT_07
#define LEDShowBitOrd_MainOnLoad        DEF_BIT_08
#else                                   
#define LEDShowBitOrd_MainOnLoad        DEF_BIT_07
#define LEDShowBitOrd_GenOnLoad         DEF_BIT_08
#endif                                  
#define LEDShowBitOrd_MainStatus        DEF_BIT_09
#define LEDShowBitOrd_WarnStatus        DEF_BIT_10
#define LEDShowBitOrd_AlarmStatus       DEF_BIT_11
#define LEDShowBitOrd_RunningSta        DEF_BIT_12


#define KeyReadDlyValue                 8           /* delay */
#define LEDoutputDlyValue               8 

typedef struct
{
 GPIO_TypeDef*     GPIOx; 
 uint16_t          GPIO_Pin;
 GPIOMode_TypeDef  GPIO_Mode;
 GPIOSpeed_TypeDef GPIO_Speed;
 uint32_t          RCC_APB2Periph;
} KeyLEDPortCfg_TypeDef;


#ifdef UsingHW72xx
#define KeyLEDPortNumber             12
#else
#define KeyLEDPortNumber             6
#endif
HCI_CFG_EXT const KeyLEDPortCfg_TypeDef KeyLEDPortcfgTable[KeyLEDPortNumber];

#define KeyValueVaildNumber          KeyVOrder_TOTNum
HCI_CFG_EXT const uint16_t KeyValueVaildTbl[KeyValueVaildNumber];
#define SinglKeyNumber               9
HCI_CFG_EXT const uint16_t SinglKeyValueTbl[SinglKeyNumber];
#define LongTouchKeyNumber           3
HCI_CFG_EXT const uint16_t LongTouchKeyValueTbl[LongTouchKeyNumber];
#define CompositeKeyNumber           5
HCI_CFG_EXT const uint16_t CompositeKeyValueTbl[CompositeKeyNumber];

#define CommKeyConvertNumber        10
HCI_CFG_EXT const uint8_t  CommuKeyConvertTbl[CommKeyConvertNumber];
//#define SMSKeyConvertNumber         4
//HCI_CFG_EXT const uint8_t SMSKeyConvertTbl[SMSKeyConvertNumber];

HCI_CFG_EXT const uint8_t ButtonTransferControlModeTbl[];
HCI_CFG_EXT const uint8_t ButtonUpdInputAuxiStaTbl[];
HCI_CFG_EXT const uint16_t HCIShowWFTiDelayEnableFlags;
HCI_CFG_EXT const uint16_t HCIShowMainDelayEnableFlags;

/* Pcfg Buffer RelayOut Config Order */                                   
#define LEDOutPcfgBFOrd_1Active                                  (Adr_LEDIndicator1Active-Adr_LEDIndicator1Active)
#define LEDOutPcfgBFOrd_1Type                                    (Adr_LEDIndicator1Type  -Adr_LEDIndicator1Active)
#define LEDOutPcfgBFOrd_2Active                                  (Adr_LEDIndicator2Active-Adr_LEDIndicator1Active)
#define LEDOutPcfgBFOrd_2Type                                    (Adr_LEDIndicator2Type  -Adr_LEDIndicator1Active)
#define LEDOutPcfgBFOrd_3Active                                  (Adr_LEDIndicator3Active-Adr_LEDIndicator1Active)
#define LEDOutPcfgBFOrd_3Type                                    (Adr_LEDIndicator3Type  -Adr_LEDIndicator1Active)
#define LEDOutPcfgBFOrd_4Active                                  (Adr_LEDIndicator4Active-Adr_LEDIndicator1Active)
#define LEDOutPcfgBFOrd_4Type                                    (Adr_LEDIndicator4Type  -Adr_LEDIndicator1Active)
#define LEDOutPcfgBFTOT_CfgNum                                   (LEDOutPcfgBFOrd_4Type+1)


/* Special Input Control Sta */
#define SpecInCtrStaOrd_AlarmMute             0
#define SpecInCtrStaOrd_InhibitAlarmStop      1
#define SpecInCtrStaOrd_PanelLock             2
#define SpecInCtrStaOrd_InhibitAutoStop       3
#define SpecInCtrStaOrd_InhibitAutoStart      4
#define SpecInCtrStaOrd_InhibitHighTempStop   5
#define SpecInCtrStaOrd_InhibitLowOilStop     6 
#define SpecInCtrStaOrd_AuxInstrumentMode     7
#define SpecInCtrStaOrd_InhibitRemoteOpera    8
#define SpecInCtrStaOrd_TOTNum                9
HCI_CFG_EXT const uint8_t SpecInControlStaListTbl[SpecInCtrStaOrd_TOTNum];


/* Auto LCD Contrast Table */
#define ContrastTbl_Limit      0
#define ContrastTbl_Offset     1
#define ContrastTbl_Level      9
HCI_CFG_EXT const int16_t AutoLCDContrastTable[ContrastTbl_Level][ContrastTbl_Offset+1];


#ifdef __cplusplus
}
#endif


#endif   /*  __HCI_CFG_H__  */

/******************* (C) COPYRIGHT 2010 Feirui *****END OF FILE****/